<?php
class lib_pdo_proxy extends PDO 
{
    private $__helper;
    
    public function prepare($sql)
    {
        $this->__helper = K::load_lib('lib_pdo_helper');
        return new lib_pdo_statment(parent::prepare($sql));
    }
    
    public function __call($func , $args)
    {
        if(substr($func , 0 , 5) == 'help_')
        {
            array_unshift($args , $this);
            return call_user_func_array(array($this->__helper , $func) , $args);
        }
        else 
            return false;
    }
}

class lib_pdo_statment
{
    private $st;
    
    public function __construct($st)
    {
        $this->st = $st;
    }
    
    public function execute()
    {
        $rs = $this->st->execute();
        if(!$rs)
            K_log::debug();
        return $rs;
    }
    
    public function __call($func , $args)
    {
        return call_user_func_array(array($this->st , $func) , $args);
    }
    
    public function __destruct()
    {
        unset($this->st);
    }
}
?>